package com.example.qxfw.cshx.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.qxfw.common.entity.zy.CshxSetting;
import com.example.qxfw.cshx.mapper.CshxSettingMapper;
import com.example.qxfw.cshx.service.CshxSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CshxSettingServiceImpl implements CshxSettingService {

    @Autowired
    private CshxSettingMapper cshxSettingMapper;

    @Override
    public List<CshxSetting> getList() {
        return cshxSettingMapper.selectAll();
    }

    @Override
    public List<CshxSetting> getList1() {
        return cshxSettingMapper.selectList(
                Wrappers.<CshxSetting>lambdaQuery().orderByDesc(CshxSetting::getValue));
    }

    @Override
    public List<String> getId() {

        return cshxSettingMapper.selectId();
    }

    @Override
    public Integer save(CshxSetting cshxSetting) {

        return cshxSettingMapper.insert(cshxSetting);
    }

    @Override
    public Integer update(CshxSetting cshxSetting) {
        Integer id = cshxSetting.getId();
        cshxSetting.setId(null);
        return cshxSettingMapper.update(cshxSetting, Wrappers.<CshxSetting>lambdaUpdate()
                .eq(CshxSetting::getId,id));
    }

    @Override
    public Integer delete(String id) {
        return cshxSettingMapper.delete(Wrappers.<CshxSetting>lambdaQuery()
                .eq(CshxSetting::getId,Integer.parseInt(id)));
    }
}
